import JoyStick from "./JoyStick";

// Learn TypeScript:
//  - [Chinese] https://docs.cocos.com/creator/manual/zh/scripting/typescript.html
//  - [English] http://www.cocos2d-x.org/docs/creator/manual/en/scripting/typescript.html
// Learn Attribute:
//  - [Chinese] https://docs.cocos.com/creator/manual/zh/scripting/reference/attributes.html
//  - [English] http://www.cocos2d-x.org/docs/creator/manual/en/scripting/reference/attributes.html
// Learn life-cycle callbacks:
//  - [Chinese] https://docs.cocos.com/creator/manual/zh/scripting/life-cycle-callbacks.html
//  - [English] http://www.cocos2d-x.org/docs/creator/manual/en/scripting/life-cycle-callbacks.html

const { ccclass, property } = cc._decorator;

@ccclass
export default class JoyStickTest extends cc.Component {

    @property({ type: cc.Label })
    label: cc.Label = null

    // onLoad () {}

    start() {
        let self = this
        self.label.node.active = true
        self.label.string = "摇杆测试输出"
        self.node.on(JoyStick.EvtUpdate, (p: cc.Vec2, d: number) => {
            self.label.string = p.toString() + "|" + d.toFixed(2)
        })
        self.node.on(JoyStick.EvtReset, () => {
            self.label.string = "重置"
        })
        self.node.on(JoyStick.EvtStart, () => {
            self.label.string = "激活"
        })
        self.node.on(JoyStick.EvtCancel, () => {
            self.label.string = "取消"
        })
    }

    // update (dt) {}
}
